HTTP streaming implementation for UTCP
The HTTP Stream provider enables streaming data transfers over HTTP using chunked transfer encoding, making it suitable for scenarios where continuous data needs to be sent over standard HTTP infrastructure without requiring specialized protocols like WebSockets or SSE.
HTTP Stream providers are configured using the following JSON structure:
{ "name": "streaming_service", "provider_type": "http_stream", "url": "https://api.example.com/stream", "http_method": "POST", "content_type": "application/json", "chunk_size": 4096, "timeout": 60000, "headers": { "User-Agent": "UTCP Client", "Accept": "text/event-stream" }, "auth": { "auth_type": "api_key", "api_key": "YOUR_API_KEY", "var_name": "X-API-Key" }, "body_field": "prompt", "header_fields": ["stream_format", "model"] }
Field | Required | Description |
---|---|---|
name |
Yes | Unique identifier for the provider |
provider_type |
Yes | Must be set to "http_stream" |
url |
Yes | Full URL to the streaming endpoint |
http_method |
No | HTTP method to use (default: "GET" ). Can be GET or POST. |
content_type |
No | Content type header (default: "application/json" ) |
chunk_size |
No | Size of chunks in bytes (default: 4096 ) |
timeout |
No | Timeout in milliseconds (default: 60000 ) |
headers |
No | Additional HTTP headers to include in the request |
auth |
No | Authentication configuration (if required) |
body_field |
No | The name of the single input field to be sent as the request body |
header_fields |
No | List of input fields to be sent as request headers |
HTTP Stream providers support the same authentication methods as standard HTTP providers:
{ "auth": { "auth_type": "api_key", "api_key": "YOUR_API_KEY", "var_name": "X-API-Key" } }
{ "auth": { "auth_type": "bearer", "token": "YOUR_BEARER_TOKEN" } }
{ "auth": { "auth_type": "basic", "username": "your_username", "password": "your_password" } }
HTTP Stream providers use chunked transfer encoding to send data in chunks. Each chunk can contain:
The client processes each chunk according to the tool's output schema and continues until the stream ends.
For HTTP Stream providers, the tool discovery endpoint should be accessible at /utcp
on the same domain as the API. For example:
https://api.example.com/utcp
The discovery endpoint should return a UTCPManual
object describing
the available streaming tools and their expected input/output formats.
{ "name": "ai_text_generator", "provider_type": "http_stream", "url": "https://ai.example.com/generate/stream", "http_method": "POST", "content_type": "application/json", "timeout": 120000, "auth": { "auth_type": "bearer", "token": "YOUR_AI_API_TOKEN" }, "body_field": "prompt", "header_fields": ["model", "max_tokens"] }
{ "name": "file_processor", "provider_type": "http_stream", "url": "https://process.example.com/files/stream", "http_method": "POST", "content_type": "application/octet-stream", "chunk_size": 8192, "timeout": 300000, "auth": { "auth_type": "api_key", "api_key": "YOUR_PROCESSING_KEY", "var_name": "X-Process-Key" } }
{ "name": "data_analyzer", "provider_type": "http_stream", "url": "https://analytics.example.com/stream", "http_method": "POST", "content_type": "application/json", "chunk_size": 2048, "timeout": 180000, "headers": { "Accept": "application/x-ndjson" }, "header_fields": ["dataset_id", "analysis_type"] }
© 2024 Universal Tool Calling Protocol. All rights reserved.